import {useSelector,useDispatch} from 'react-redux'
import {ICounterModuleState} from '../types'
import {increment,decrease} from '../store/reducers/counter'
export default function Counter() {
  const dispatch=useDispatch()
  const count=useSelector((state)=>{
    console.log('state',state);
    return state.counter.count
  })
  const incr=()=>{
    dispatch(increment())
  }
  const subcr=()=>{
    dispatch(decrease())
  }
  return (
    <div>
        <h1>计数器</h1>
        <div>{count}</div>
        <button onClick={()=>{incr()}}>+</button>
        <button onClick={()=>{subcr()}}>-</button>
    </div>
  )
}
